package de.hska.kundenverwaltung.rest;

import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;


import de.hska.util.Xlink;

@XmlRootElement(name="kunde")
@XmlSeeAlso({
    FirmenkundeData.class,
    PrivatkundeData.class
})
public abstract class KundeData {
	@XmlAttribute(name="id", required=true)
	public long id = Long.MIN_VALUE;
	
	@XmlElement(required=true)
	public String nachname = "Nicht gefunden";
	
	@XmlElementWrapper(name="bestellungen")
	public List<Xlink> bestellung;   // Keine Interfaces bei Daten fuer Web Services
	
	@XmlElement(required=true)
	public Kundenart art = Kundenart.privatkunde;
	
	public KundeData() {
		super();
	}


	@Override
	public String toString() {
		return "{id=" + id + ", nachname=" + nachname + ", art=" + art + '}';
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result
				+ ((nachname == null) ? 0 : nachname.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final KundeData other = (KundeData) obj;
		if (id != other.id)
			return false;
		if (nachname == null) {
			if (other.nachname != null)
				return false;
		} else if (!nachname.equals(other.nachname))
			return false;
		return true;
	}
}